<template>
    <!-- 供应商下级汇总明细 -->
    <div class="e-table billList">
        <el-form>
            <div style="display: flex; justify-content: space-between">
                <div style="margin-left: 10px">
                    <div>
                        <span style="margin-left: 10px">共：{{ 30 }}条</span>
                        <span style="margin-left: 10px"
                            >供应商名称：{{ 1111 }}</span
                        >
                    </div>
                </div>
                <div style="display: flex; margin-right: 10px">
                    <div>
                        <span>评价等级：</span>
                        <el-radio-group v-model="tableData.taxTypeKey">
                            <el-radio
                                v-for="item in payTaxesTypeList"
                                :key="item.id"
                                :disabled="item.disabled"
                                :label="item.name"
                                :value="item.id"
                            ></el-radio>
                        </el-radio-group>
                    </div>
                    <div>
                        <el-input
                            placeholder=""
                            v-model="advancedQuery.keyword"
                            @keyup.enter.native="getData"
                        >
                            <i
                                slot="suffix"
                                style="cursor: pointer"
                                @click="getData"
                                class="el-icon-search"
                            ></i>
                        </el-input>
                    </div>
                </div>
            </div>
        </el-form>
        <el-table
            :data="tableData"
            border
            style="width: 100%"
            ref="table"
            class="table"
            :max-height="$store.state.tableHeight"
            :header-cell-style="{ textAlign: 'center' }"
            :cell-style="{ textAlign: 'center' }"
            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
        >
            <el-table-column type="selection" width="60"> </el-table-column>
            <el-table-column prop="a" label="序号" width="60">
            </el-table-column>
            <el-table-column prop="b" label="评价等级" width="200">
            </el-table-column>
            <el-table-column prop="b" label="评价意见" min-width="400">
            </el-table-column>
            <el-table-column prop="b" label="评价机构" min-width="400">
            </el-table-column>
        </el-table>
        <ComPagination
            :total="totalCount"
            :pageSize.sync="advancedQuery.limit"
            :currentPage.sync="advancedQuery.page"
            @currentChange="currentChange"
            @sizeChange="sizeChange"
        />
    </div>
</template>
<script>
import ComPagination from '@/components/pagination/pagination.vue'
import { advanceSearch } from '@/utils/common.js'
//审核
import examine from '@/api/OutsourcingartyAdmin/subcontractorAdmin/examine.js'
import { mapMutations } from 'vuex'

export default {
    components: {
        ComPagination
    },
    data () {
        return {
            selActive: '', //动态class样式
            isBatch: false, //是否进入批量操作
            batch: '进入批量管理',
            dialogVisibleSearch: false,
            searchIpt: '',
            input1: '',
            value1: '',
            value2: '',
            tableData: [
                {
                    subcontractorName: '', //工程分包商名称
                    registerCapital: '', //注册资本
                    creditCode: '', //统一社会信用代码
                    manageOrgName: '', //管理单位
                    businessScopeName: '', //主营范围
                    qualificationLevelName: '', //资质等级
                    creditLevel: '', //信用等级
                    state: '', //状态
                    type: '', //类型
                    theStatus: '' //变更状态
                }
            ],
            type: '', //父级页面控制按钮展示字段
            advancedQuery: {
                creditGrade: [], //信用等级
                grade: [], //资质等级
                isAbroadUnit: null, //境外单位
                keyword: '', //	模糊查询关键字
                limit: 20, //每页显示条数
                main: [], //主营范围
                manageOrg: [], //管理单位
                orgId: '', //单据机构
                outerType: [], //外包方类型
                page: 1, //当前页数
                startCapital: null, //开始注册资本
                endCapital: null, //结束注册资本
                states: [], //单据状态
                creditCode: '', //信用代码
                subcontractorName: '' //分包商名称
            },
            payTaxesTypeList: [
                { id: '0', name: '全部' },
                { id: '1', name: 'A' },
                { id: '2', name: 'B' },
                { id: '3', name: 'C' },
                { id: '4', name: 'D' }
            ],
            totalCount: 0, //总页数
            loading: true
        }
    },
    created () {
        // this.type = this.$router.query.type
        this.getData()
    },
    computed: {
        // 判断状态
        statusLable () {
            return param => {
                const state = this.$store.state.equip.equipData.state
                const obj = state.find(x => x.value == param)
                if (obj !== undefined) {
                    return obj.label
                }
            }
        }
    },
    methods: {
        ...mapMutations(['setSelectedInfo']),
        //批量管理
        batchOperation () {
            this.isBatch = !this.isBatch
            if (this.isBatch) {
                this.batch = '退出批量管理'
                this.$refs.table.clearSelection()
            } else {
                this.batch = '进入批量管理'
            }
        },
        //查询分包商列表数据
        getData () {
            this.loading = true
            this.selActive = 'all'
            // this.$Ajax
            //     .httpPost({
            //         url: '/outer/subcontractor/listByEntity',

            //         params: this.advancedQuery
            //     })
            //     .then(res => {
            //         setTimeout(() => {
            //             this.tableData = res.list
            //             this.totalCount = res.totalCount
            //         }, 500)
            //     })
            this.loading = false
        },
        //新增按钮
        buttonAdd () {
            this.$router.push('/subcontractorAdd')
        },

        //点击表格
        tableDbEdit (billid) {
            this.$router.push({
                path: '/subcontractorEdit',
                query: { billid }
            })
        },
        //点击表格查看
        Examine (row) {
            //点击进入查看页面
            const billid = row.id
            if (row.state === -1 || row.state === 2 || row.state === 5) {
                this.$router.push({
                    path: '/subcontractorExamine',
                    query: { billid }
                })
            } else {
                // 根据按钮状态来判断点击编辑进什么页面
                examine
                    .getCurrentUnitInfo({
                        billId: billid,
                        billType: 6040,
                        freeNextUnitIndex: 0,
                        freeNextUser: '',
                        isPass: true,
                        isShareInAudit: true,
                        opinion: ''
                    })
                    .then(res => {
                        this.auditState = res
                        if (this.auditState.canModify) {
                            this.$router.push({
                                path: '/subcontractorEdit',
                                query: { billid }
                            })
                        } else {
                            this.$router.push({
                                path: '/subcontractorExamine',
                                query: { billid }
                            })
                        }
                    })
            }
        },
        //合格
        qualified () {
            this.selActive = 'qualified'
            this.loading = true
            this.$Ajax
                .httpPost({
                    url: '/outer/subcontractor/listByQualifiedEntity',
                    params: {
                        creditcode: '',
                        keyword: '',
                        limit: this.advancedQuery.limit,
                        number: '',
                        page: this.advancedQuery.page,
                        subcontractorname: ''
                    }
                })
                .then(res => {
                    setTimeout(() => {
                        console.log(111, res)
                        this.tableData = res.list
                        this.totalCount = res.totalCount
                        this.loading = false
                    }, 500)
                })
        },
        //不合格
        NoQualified () {
            this.selActive = 'NoQualified'
            this.loading = true
            this.$Ajax
                .httpPost({
                    url: '/outer/subcontractor/listByUnqualifiedEntity',
                    params: {
                        creditcode: '',
                        keyword: '',
                        limit: this.advancedQuery.limit,
                        number: '',
                        page: this.advancedQuery.page,
                        subcontractorname: ''
                    }
                })
                .then(res => {
                    setTimeout(() => {
                        this.tableData = res.list
                        this.totalCount = res.totalCount
                        this.loading = false
                    }, 500)
                })
        },
        //黑名单
        blacklist () {
            this.selActive = 'blacklist'
            this.loading = true
            this.$Ajax
                .httpPost({
                    url: '/outer/subcontractor/listByBlackEntity',
                    params: this.advancedQuery
                })
                .then(res => {
                    setTimeout(() => {
                        this.tableData = res.list
                        this.totalCount = res.totalCount
                        this.loading = false
                    }, 500)
                })
        },
        //翻页
        currentChange () {
            this.getData()
        },
        //改变条数
        sizeChange () {
            this.getData()
        },
        //高级查询
        onAdvanceSearch () {
            advanceSearch('/subcontractorSearch?type=1').then(res => {
                this.advancedQuery.outerType = res.subcontractorTypeValue //外包方类型
                this.advancedQuery.isAbroadUnit = res.isAbroadUnit //境外单位
                this.advancedQuery.creditGrade = res.creditLevelTypeValue //信用等级
                this.advancedQuery.states = res.stateTypeValue //状态
                this.advancedQuery.startCapital = res.startCapital //开始资本
                this.advancedQuery.endCapital = res.endCapital //结束资本
                this.advancedQuery.grade = res.grade //资质等级
                this.advancedQuery.main = res.main //主营范围
                this.advancedQuery.manageOrg = res.manageOrg //管理单位
                this.advancedQuery.subcontractorName = res.subcontractorName //分包商名称
                this.advancedQuery.creditCode = res.creditCode //信用代码
                this.getData()
            })
        }
    }
}
</script>
<style lang="scss" scoped>
.like {
    background-color: #409eff;
    color: white;
}
.e-table ::v-deep.el-table__cell.is-left {
    text-align: left;
}
::v-deep .el-table__body-wrapper::-webkit-scrollbar {
    width: 6px; // 横向滚动条
    height: 10px; // 纵向滚动条
}
// 滚动条的滑块
::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: 5px;
}
::v-deep .el-button:focus,
.el-button:hover {
    background-color: #409eff;
    color: white;
}
</style>
